//
//  Date+Extension.swift
//  FG
//
//  Created by 红沙尘 on 2018/12/12.
//  Copyright © 2018年 红沙尘. All rights reserved.
//

import Foundation

extension Date{
    
    // 获取星期几
    
    func weekDay() -> String {
        let weekDays = [NSNull.init(),"周日","周一","周二","周三","周四","周五","周六"]as [Any]
        let calendar = NSCalendar.init(calendarIdentifier: .gregorian)
        let timeZone = NSTimeZone.init(name:"Asia/Shanghai")
        calendar?.timeZone = timeZone! as TimeZone
        let calendarUnit = NSCalendar.Unit.weekday
        let theComponents = calendar?.components(calendarUnit, from:self)
        return weekDays[(theComponents?.weekday)!]as! String
    }
    

}
